<template>
  <div class="big-box">
    <!-- <div class="box"> -->
    <el-form :inline="true" class="demo-form-inline">
      <el-form-item label="活动区域">
        <!-- <el-select placeholder="活动区域">
          <el-option label="区域一" value="0"></el-option>
          <el-option label="区域二" value="1"></el-option>
        </el-select>-->
      </el-form-item>
      <el-form-item label="审批人">
        <el-input placeholder="审批人"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button icon="el-icon-search">搜索</el-button>
        <el-button icon="el-icon-share ">重置</el-button>
      </el-form-item>
    </el-form>
    <!-- </div> -->
    <el-button style="margin-right:30px" type="primary">新增题库</el-button>
    <el-checkbox>只看我创建的</el-checkbox>

    <el-table border :data="questionList.list" style="margin-top:10px">
      <el-table-column type="selection" width="55"></el-table-column>
      <el-table-column label="题库名称" prop="name"></el-table-column>
      <el-table-column label="所属分类" prop="classify"></el-table-column>
      <el-table-column label="题目数" prop="ques_amount"></el-table-column>
      <el-table-column label="创建人" prop="creator"></el-table-column>
      <el-table-column label="更新时间" prop="created_at">
        <template slot-scope="scope">{{scope.row.created_at | formatDate}}</template>
      </el-table-column>
      <el-table-column fixed="right" label="操作">
        <template slot-scope="scope">
          <el-link :underline="false" type="primary" size="mini">管理试题</el-link>-
          <el-link :underline="false" type="primary" size="mini">编辑</el-link>-
          <el-link :underline="false" type="primary" size="mini" @click="del(scope.row.id)">删除</el-link>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
import { del } from "../../api";
import { question } from "../../api";
export default {
  name: "",
  data() {
    return {
      questionList: [],
      pagination: {
        page: "1",
        limit: "2",
        name: "",
        uld: "",
        classify: ""
      }
    };
  },
  mounted() {
    this.getlist();
  },
  methods: {
    async getlist() {
      let res = await question(this.pagination);
      console.log(res.data.list);
      this.questionList = res.data;
    },
    del(id) {
      this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          let res = del(id);
            console.log(res);
            this.getlist();
          this.$message({
            type: 'success',
            message: '删除成功!',
          });
          this.getlist();
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          });          
        }).finally(()=>{
         this.getlist();
        console.log('666')
        })
    }
  },
  computed: {},
  watch: {}
};
</script>
<style scoped>
</style>